package com.wzy.orderSystem.controller;

import com.wzy.orderSystem.pojo.food_detail;
import com.wzy.orderSystem.service.impl.opFoodDetailImpl;

import java.util.List;

public class foodDetailController {
   private static opFoodDetailImpl ofd =  new  opFoodDetailImpl();

    //根据菜品id查询菜品信息
    public static void selectByName(int id){
        List<food_detail> food_details = ofd.selectById(id);
        for(food_detail fd : food_details){
            System.out.println("菜品id为"+id+"的菜品信息如下：");
            System.out.println("菜品id为-->"+fd.getId());
            System.out.println("菜品名为-->"+fd.getFoodName());
            System.out.println("菜品价格为-->"+fd.getFoodPrice());
            System.out.println("菜品介绍为-->"+fd.getFoodInfo());
            System.out.println("菜品类别为-->"+fd.getFoodClassify());
            System.out.println("菜品喜欢的用户为-->"+fd.getFavorite());
            System.out.println("菜品图片为-->"+fd.getFoodPic());
        }
    }

    //根据菜品名删除菜品
    public static void deleteByName(String foodName){
        int i = ofd.deleteByName(foodName);
        System.out.println(i>0?"删除成功！":"删除失败！");
    }

    //根据菜品名修改菜品价格
    public static void updateByName(String foodName, int foodPrice){
        int i = ofd.updateByName(foodName, foodPrice);
        System.out.println(i>0?"修改成功！":"修改失败！");
    }

    //添加菜品
    public static void insertFood(int id, String foodName, int foodPrice, String foodInfo, String classify, int favorite, String foodPic){
        int insert = ofd.insert(id, foodName, foodPrice, foodInfo, classify, favorite, foodPic);
        System.out.println(insert>0?"新增成功！":"新增失败！");
    }

}
